package com.test.pudamoney.activity_fragment_pudamoney.fragment_pudamoney;

import android.annotation.SuppressLint;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.test.pudamoney.R;
import com.test.pudamoney.constant_pudamoney.Constant_pudamoney;
import com.test.pudamoney.activity_fragment_pudamoney.base_pudamoney.BaseFragment_pudamoney;

public class DataSafetyFragment_pudamoney extends BaseFragment_pudamoney {

    private WebView webView_pudamoney;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_data_safety_pudamoney, container, false);
        init_pudamoney(view);
        return view;
    }

    private void init_pudamoney(View view) {
        //初始化配置
        initWebViewConfigs_pudamoney(view);

        webView_pudamoney.loadUrl(Constant_pudamoney.Privacy_Nigeria);

    }

    @SuppressLint({"SetJavaScriptEnabled", "ObsoleteSdkInt"})
    private void initWebViewConfigs_pudamoney(View view) {
        webView_pudamoney = view.findViewById(R.id.fragment_data_safety_web_view);
        webView_pudamoney.setInitialScale(100);
        webView_pudamoney.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return false;
            }

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
                return shouldOverrideUrlLoading(view, request.getUrl().toString());
            }
        });

        WebSettings settings = webView_pudamoney.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setTextZoom(100);
        settings.setSupportZoom(true);
        settings.setUseWideViewPort(true);
        settings.setUseWideViewPort(true);
        settings.setDomStorageEnabled(true);
        settings.setBuiltInZoomControls(true);
        settings.setLoadWithOverviewMode(true);
        settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            settings.setAllowUniversalAccessFromFileURLs(true);
            settings.setAllowFileAccessFromFileURLs(true);
            settings.setAllowContentAccess(true);
        }
    }
}